<template> 
  <div class="app-container">
    <el-card class="filter-container" shadow="never">
      <div>
        <i class="el-icon-search"></i>
        <span>筛选搜索</span>
        <el-button style="float:right" type="primary" @click="handleSearchList()" size="s米糕">
          查询搜索
        </el-button>
        <el-button style="float:right;margin-right: 15px" @click="handleReset(),handleResetSearch()" size="s米糕">
          重置
        </el-button>
      </div>
      <div style="margin-top: 15px">
        <el-form :inline="true" :model="listQuery" size="s米糕" label-width="140px">
          <el-form-item label="输入搜索：">
            <el-input v-model="listQuery.username" class="input-width" placeholder="用户名" clearable>
            </el-input>
          </el-form-item>
          <el-form-item label="手机号：">
            <el-input v-model="listQuery.mobilePhone" class="input-width" placeholder="手机号" clearable>
            </el-input>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <!-- <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
      <el-button size="mini" class="btn-add" @click="handleAdd()" style="margin-left: 20px">添加</el-button>
    </el-card> -->
    <div class="table-container">
      <el-table ref="adminTable" :data="list" style="width: 100%;" v-loading="listLoading" border>
        <el-table-column label="编号" width="100" align="center">
          <template slot-scope="scope">{{ scope.row.id }}</template>
        </el-table-column>
        <el-table-column label="头像" width="200" align="center">
          <template slot-scope="scope"><img width="100" height="100" :src="ossURL + scope.row.avatar" /></template>
        </el-table-column>
        <el-table-column label="帐号" align="center">
          <template slot-scope="scope">{{ scope.row.username }}</template>
        </el-table-column>
        <el-table-column label="昵称" align="center">
          <template slot-scope="scope">{{ scope.row.nickname }}</template>
        </el-table-column>
        <el-table-column label="邮箱" align="center">
          <template slot-scope="scope">{{ scope.row.email}}</template>
        </el-table-column>
        <el-table-column label="生日" width="160" align="center">
          <template slot-scope="scope">{{ scope.row.birthday | formatDateTime }}</template>
        </el-table-column>
        <el-table-column label="添加日期" width="160" align="center">
          <template slot-scope="scope">{{ scope.row.createTime | formatDateTime }}</template>
        </el-table-column>
        <el-table-column label="手机号" width="140" align="center">
          <template slot-scope="scope">{{ scope.row.mobilePhone }}</template>
        </el-table-column>

        <el-table-column label="铸造的nft数量" align="center">
          <template slot-scope="scope">{{ scope.row.buildNftNumber}}</template>
        </el-table-column>
        <el-table-column label="拥有的nft数量" align="center">
          <template slot-scope="scope">{{ scope.row.transactionNumber }}</template>
        </el-table-column>
        
        <el-table-column label="性别" align="center">
          <template slot-scope="scope">{{ sex[scope.row.gender] }}</template>
        </el-table-column>

      </el-table>
    </div>
    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper" :current-page.sync="listQuery.pageNum"
        :page-size="listQuery.pageSize" :page-sizes="[15]" :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { UserController } from '../../components/SelectUser/index';
import {formatDate} from '@/utils/date';
import { getUserListBySearch } from  "../../api/user"
const user = new UserController();

export default {
  data() {
    return user.getCurrentData()
  },

  watch: {
    'listQuery.username': (val) => {
      // console.log("val", val);



      // user.set("listQuery", this.listQuery)
    }
  },
  filters: {
    formatDateTime (time) {
      if (time == null || time === '') {
        return 'N/A';
      }
      let date = new Date(time*1000);
      return formatDate(date, 'yyyy-MM-dd')
    }
  },

  methods: {
    ...user.methods,
    handleSearchList(val) {
      getUserListBySearch(this.listQuery, this)
    },
    handleReset(){
      
      user.created(this)
    }
  },



  created() {
    user.created(this)
  }
}

</script>


